﻿using CZBK.ShopHeima2.IDAL;
using CZBK.ShopHeima2.Model;
using System;
using System.Collections.Generic;
using System.Data.Entity;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace CZBK.ShopHeima2.DAL
{

    public partial class DbSession : IDbSession
    {
        DbContext db = DbContextFactory.CreateDbContext();
        private IProductRepository _ProductRepository;
        public IProductRepository ProductRepository
        {
            get
            {

                if (_ProductRepository == null)
                {
                    _ProductRepository = new ProductRepository();
                }
                return _ProductRepository;
            }
            set { _ProductRepository = value; }
        }
        private IUserInfoRepository _UserInfoRepository;
        public IUserInfoRepository UserInfoRepository
        {
            get
            {

                if (_UserInfoRepository == null)
                {
                    _UserInfoRepository = new UserInfoRepository();
                }
                return _UserInfoRepository;
            }
            set { _UserInfoRepository = value; }
        }

        public int ExecuteSql(string strSql, System.Data.SqlClient.SqlParameter[] paras)
        {
            return db.Database.ExecuteSqlCommand(strSql,paras);
        }

        public int SavaChanges()
        {
           return  db.SaveChanges();
        }
    }
}
